package com.tsc.design.responsibilityMode.example;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: chentl
 * @Date: 2025/09/17/17:41
 * @Description:
 */
public class LoggerChainExample {
    public static void main(String[] args) {
        Logger logger = getChainOfLoggers();
        logger.logMessage(LogLevel.DEBUG, "This is a debug level message.");
        System.out.println();
        logger.logMessage(LogLevel.INFO, "This is an info level message.");
        System.out.println();
        logger.logMessage(LogLevel.WARN, "This is a warn level message.");
    }

    public static Logger getChainOfLoggers(){
        Logger consoleLogger = new ConsoleLogger(LogLevel.DEBUG);
        Logger fileLogger = new FileLogger(LogLevel.INFO);
        Logger databaseLogger = new DatabaseLogger(LogLevel.ERROR);
        consoleLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(databaseLogger);
        return consoleLogger;
    }
}
